Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export targets #403

Merged
merged 17 commits into from
May 20, 2020
Merged

export targets #403

merged 17 commits into from
May 20, 2020

Conversation

Karsten1987
Copy link
Collaborator

@Karsten1987 Karsten1987 commented May 4, 2020

Closes #402
Requires ros/pluginlib#190

@Karsten1987 Karsten1987 self-assigned this May 4, 2020
@Karsten1987
Copy link
Collaborator Author

Karsten1987 commented May 4, 2020

This is currently work in progress.

I am facing the following CMake error which I have to figure out what's happening:

--- stderr: rosbag2_storage

CMake Error: install(EXPORT "export_rosbag2_storage" ...) includes target "rosbag2_storage" which requires target "tinyxml2_vendor" that is not in any export set.
CMake Generate step failed.  Build files cannot be regenerated correctly.
---
Failed   <<< rosbag2_storage	[ Exited with code 1 ]

I honestly have no real clue why rosbag2_storage should depend on tinyxml2_vendor. I can't see an immediate dependency on it.

@Karsten1987
Copy link
Collaborator Author

The above error could be resolved by ros/pluginlib#190. With that PR, I am putting this PR out of draft mode.

I think the exported targets look decent so far. There's no abosolute path in it. The absolute path for the include directories are coming from other packages as far as I can tell.

set_target_properties(rosbag2_transport::rosbag2_transport PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/Users/karsten/workspace/ros2/ros2_master/install/include;/Users/karsten/workspace/ros2/ros2_master/install/opt/yaml_cpp_vendor/lib/cmake/yaml-cpp/../../../include"
  INTERFACE_LINK_LIBRARIES "rcl::rcl;rclcpp::rclcpp;rcutils::rcutils;rmw::rmw;rosbag2_compression::rosbag2_compression;rosbag2_compression::rosbag2_compression_zstd;rosbag2_cpp::rosbag2_cpp;yaml-cpp"
)

@Karsten1987 Karsten1987 marked this pull request as ready for review May 5, 2020 18:19
@Karsten1987
Copy link
Collaborator Author

@emersonknapp @zmichaels11 Maybe you can help me out. I honestly don't really get how that zstd_vendor package is working. Especially the line in here:

ament_export_libraries(zstd)

What is zstd in this case?

From what I can see here zstd does use already exported cmake targets and we should actually just leverage these. However, I am somewhat confused that there is no find_package(zstd) within rosbag2_compression.

@zmichaels11
Copy link
Contributor

@emersonknapp @zmichaels11 Maybe you can help me out. I honestly don't really get how that zstd_vendor package is working. Especially the line in here:

ament_export_libraries(zstd)

What is zstd in this case?

From what I can see here zstd does use already exported cmake targets and we should actually just leverage these. However, I am somewhat confused that there is no find_package(zstd) within rosbag2_compression.

@piraka9011 do you have input on this design choice?

@emersonknapp
Copy link
Collaborator

I'm not too familiar with the compression code either - it seems like it's just declaring the preexisting library, either system installed or built via ExternalProject - as an ament target?

@Karsten1987
Copy link
Collaborator Author

So I worked around this now by providing a Findzstd.cmake similar to what is done in the sqlite3_vendor package. I've figured out that version 1.4.4 of zstd does not provide any modern CMake logic (neither a find_package so to speak).

@piraka9011
Copy link
Contributor

@Karsten1987 zstd does not have modern CMake exports as you described so instead I exported the library as zstd_vendor and linked using the zstd_vendor_INCLUDE_DIRS and zstd_vendor_LIBRARIES CMake variables.

@dirk-thomas
Copy link
Member

I would suggest to split the non-export target related changes into a separate PR to make this easier to review.

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good. There are a few cleanups in here that could be punted out to a separate PR just to keep this one a little smaller. I have one question inline.

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sqlite3_install/ DESTINATION ${CMAKE_INSTALL_PREFIX})
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sqlite3_install/
DESTINATION .)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this based on this comment: ros2/console_bridge_vendor#9 (review)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was changed under the impression that older CMake versions had an issue otherwise. I would guess that was won't the problem was coming from somewhere else. So referring that change sounds reasonable.

@Karsten1987
Copy link
Collaborator Author

I am okay with splitting this PR.

I think I could do the following, which could hopefully be merged individually:

  • changing to modern cmake targets
  • make rosbag2 relocatable (specifically their vendor packages)
  • general touchups

@@ -5,8 +5,9 @@ find_package(ament_cmake REQUIRED)

include(ExternalProject)
# Single producer single consumer queue by moodycamel - header only, don't build, install
ExternalProject_Add(singleproducerconsumer
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/single
ExternalProject_Add(ext-singleproducerconsumer
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately left in these changes because the cmake target of the ExternalProject_Add would collide with add_library.

@Karsten1987
Copy link
Collaborator Author

I would ask for another round of review here. I hope I could strip down the packages well enough to make the changes easier to grasp.

Copy link
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I will leave the actual approval to one of the maintainers.)

list(APPEND zstd_TARGETS zstd::zstd)
else()
message(FATAL_ERROR "Unable to find zstd")
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this package doesn't use linters yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not and but can be added in a follow up PR.

ament_export_dependencies(pluginlib
rosbag2_storage
rosidl_runtime_c
rosidl_runtime_cpp
rosidl_typesupport_cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, when importing a cmake target, all dependencies have to present at cmake's generation step as opposed to using ${<pkg>_LIBRARIES} which is applied during linking. It's therefore important to export all necessary dependencies.

endif()
list(APPEND zstd_TARGETS zstd::zstd)
else()
message(FATAL_ERROR "Unable to find zstd")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I usually try to exit early to avoid indentation, like:

if(NOT zstd_FOUND)
  message(FATAL_ERROR "Unable to find zstd")
endif()

...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exiting early is preferred.

There was actually another problem in here though, in that it would fail (FATAL_ERROR) regardless whether find_package(zstd) was called with REQUIRED or not. So I've changed that. With this however, I don't see a good way of exiting earlier anymore.

Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Knese Karsten <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: Karsten Knese <[email protected]>
@Karsten1987 Karsten1987 merged commit ead6f74 into master May 20, 2020
@delete-merged-branch delete-merged-branch bot deleted the export_targets branch May 20, 2020 16:51
pjreed pushed a commit to pjreed/rosbag2 that referenced this pull request May 28, 2020
* wip export targets

Signed-off-by: Karsten Knese <[email protected]>

* correct include dirs

Signed-off-by: Karsten Knese <[email protected]>

* relative include paths for vendor packages

Signed-off-by: Karsten Knese <[email protected]>

* cleanup rosbag2_test_common

Signed-off-by: Karsten Knese <[email protected]>

* cleanup shared_queues_vendor package

Signed-off-by: Karsten Knese <[email protected]>

* cleanup sqlite3 vendor package

Signed-off-by: Karsten Knese <[email protected]>

* cleanup zstd_vendor package

Signed-off-by: Karsten Knese <[email protected]>

* cleanup rosbag2_compression

Signed-off-by: Karsten Knese <[email protected]>

* touchups for isolated build

Signed-off-by: Knese Karsten <[email protected]>

* export typesupport

Signed-off-by: Karsten Knese <[email protected]>

* organize included dependencies

Signed-off-by: Karsten Knese <[email protected]>

* unknown import target for sqlite3

Signed-off-by: Karsten Knese <[email protected]>

* try debugging windows

Signed-off-by: Karsten Knese <[email protected]>

* remove fatal error warning

Signed-off-by: Karsten Knese <[email protected]>

* limit amount of change

Signed-off-by: Karsten Knese <[email protected]>

* use CMAKE_INSTALL_PREFIX

Signed-off-by: Karsten Knese <[email protected]>

* fatal_error only when required

Signed-off-by: Karsten Knese <[email protected]>
Signed-off-by: P. J. Reed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make rosbag2 related packages relocatable
6 participants